package com.lagou.edu.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

public class Handler {

    // 存储controller对象
    private Object controller;
    // 存储方法
    private Method method;
    // 存储URL，类似String，但它支持正则表达式
    private Pattern pattern;
    // 存储参数及参数顺序，key是参数名，value代表是第几个参数 <name,2>
    private Map<String, Integer> paramIndexMapping;

    // 保存有权限访问的username
    private List<String> securityNames;

    public Handler(Object controller, Method method, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
        this.securityNames = new ArrayList<String>();
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }

    public List<String> getSecurityNames() {
        return securityNames;
    }

    public void setSecurityNames(List<String> securityNames) {
        this.securityNames = securityNames;
    }
}
